require(["./config"], () => {
  require(["swiper", "url", "template", "header", "footer"], (
    Swiper,
    url,
    template
  ) => {
    class Index {
      constructor() {
        this.banner();
        this.ListBanner();
        this.ListContent();
        this.ListContents();
      }
      banner() {
        new Swiper(".swiper-container", {
          loop: true,
          autoplay: true,

          // 如果需要分页器
          pagination: ".swiper-pagination",

          // 如果需要前进后退按钮
          nextButton: ".swiper-button-next",
          prevButton: ".swiper-button-prev"
        });
      }
      ListBanner() {
        // console.log(11111);
        $.get(url.baseUrl + "/listbanner", resp => {
          // console.log(resp);
          if (resp.code === 200) {
            const { banner } = resp.body;
            // console.log(resp.body);
            $("#Listbanner").html(template("getListbanner", { list: banner }));
          }
        });
      }
      ListContent() {
        $.get(url.baseUrl + "/listContent", resp => {
          // console.log(resp);
          if (resp.code === 200) {
            const { listcontent } = resp.body;
            // console.log(listcontent);
            $("#ListContent").html(
              template("getListContent", { list: listcontent })
            );
          }
        });
      }
      ListContents() {
        $.get(url.baseUrl + "/listContent", resp => {
          // console.log(resp);
          if (resp.code === 200) {
            const { listcontent } = resp.body;
            // console.log(listcontent[0]);
            $("#ListContents").html(
              template("getListContents", { list: listcontent[0] })
            );
          }
        });
      }
    }
    new Index();
  });
});
